package leetcode_201_300;

public class LeeCode_201 {
    public static void main(String[] args) {
        System.out.println(rangeBitwiseAnd(5, 7));
        System.out.println(rangeBitwiseAnd(0, 0));
    }
    private static int rangeBitwiseAnd(int left, int right) {
        int offset = 0;
        while (left != right){
            left >>= 1;
            right >>= 1;
            offset++;
        }
        return right << offset;
    }
}
